home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / matchesplayed.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  8KB  |  296 lines

  1. /* Mode=Set */
  2. /* ***********************************************************************
  3.  
  4.    MATCHES PLAYED PROGRAM FOR FOOTBALL REXX SUITE
  5.   ------------------------------------------------
  6.                    Copyright  Mark Naughton 1997
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       050197   First release.
  12.            060197   Added check so that it exits if the teams play each
  13.                     other more than twice.
  14.            110197   Forgot to initialise the variable used above. Name
  15.                     changed from 'GamesToBePlayed' to 'GamesPlayed'.
  16.            110197   Now shows all games played by selected team.
  17.            170197   Fixed bug where it displayed the team selected
  18.                     instead of skipping it.
  19.            151297   Now shows selected team's score first in Away matches
  20.                     as well. Tidied display.
  21.            210499   Added check for no team specified.
  22.  1.1       150599   Name change. Started adding support for other types
  23.                     of playing each team - from 1 to 10; all works ok.
  24.            250899   Added error msg for file checks.
  25.            110999   Converted to use locale. Some error messages, before
  26.                     reading the locale, will still be in English.
  27.  
  28. **************************************************************************
  29.  
  30. Procedure
  31. ---------
  32.  
  33. 1. Check files exist. Read Teams.df datafile and store teams.
  34. 3. Open Schedule datafile.
  35. 4. Use selected team against either HOME or AWAY team and store the score
  36.    if a match has been played. Otherwise increment matches_to_play.
  37. 5. Close file. Display data then exit...
  38.  
  39. ************************************************************************** */
  40. PARSE ARG league_stuff
  41.  
  42. version      = 1
  43. input_file   = '.df'
  44. input2_file  = '.sf'
  45. title        = '*LEAGUE_NAME='
  46. playeo       = '*PLAY_OTHER='
  47. separator    = '*'
  48. teams.       = '???'
  49. teams2.      = '???'
  50. counter      = 0
  51. not_played   = '__   __'
  52. home.        = '???'
  53. away.        = '???'
  54. matches.     = '???'
  55. numplay      = 2
  56. oddn         = '1 3 5 7 9'
  57. evenn        = '2 4 6 8 10'
  58.  
  59.  
  60. parse var league_stuff league_file search_team
  61. league_file = "Data/" || league_file
  62.  
  63. if open(datafile,"Data/Football.locale",'r') then do
  64.    line = readln(datafile)
  65.    locdir = strip(line)
  66.    close(datafile)
  67. end
  68. else do
  69.    say
  70.    say "ERROR :    (MatchesPlayed)"
  71.    say
  72.    say "Cannot read 'Data/Football.locale' for the locale settings."
  73.    exit
  74. end
  75.  
  76. locdir = locdir"User/MatchesPlayed.data"
  77.  
  78. if open(datafile,"ENV:FootballRXPath",'r') then do
  79.    line = readln(datafile)
  80.    rxdir = strip(line)
  81.    close(datafile)
  82. end
  83. else
  84.    rxdir = "SYS:Rexxc/"
  85.  
  86. if exists(locdir) > 0 then do
  87.   address command rxdir'rx 'locdir
  88.   VarCount = getclip('VarCount')
  89.   do i = 1 to VarCount
  90.     interpret getclip('var.'i)
  91.   end
  92. end
  93. else do
  94.    say
  95.    say "ERROR :    (MatchesPlayed)"
  96.    say
  97.    say "Cannot find '"locdir"' to read locale settings."
  98.    exit
  99. end
  100.  
  101. if exists(league_file || input_file) = 0  then do
  102.    say
  103.    say mp_error
  104.    say
  105.    say mp_t1"'"league_file || input_file"'."
  106.    exit
  107. end
  108.  
  109. if exists(league_file || input2_file) = 0 then do
  110.    say
  111.    say mp_error
  112.    say
  113.    say mp_t1"'"league_file || input2_file"'."
  114.    exit
  115. end
  116.  
  117. if search_team = "" then do
  118.    say
  119.    say mp_error
  120.    say
  121.    say mp_t4
  122.    say
  123.    say mp_t5
  124.    say
  125.    exit
  126. end
  127.  
  128.  
  129. if open(datafile,league_file || input_file,'r') then do
  130.    do while ~eof(datafile)
  131.       line = readln(datafile)
  132.       if pos(title,line) > 0 then
  133.          league_title = delstr(line,1,13)
  134.       if pos(playeo,line) > 0 then
  135.          numplay = delstr(line,1,12)
  136.       if pos(separator,line) = 0 then do
  137.          line = strip(line)
  138.          if counter = 0 then do
  139.             teams.1 = line
  140.             counter = 1
  141.          end
  142.          else do
  143.             counter       = counter + 1
  144.             teams.counter = line
  145.          end
  146.       end
  147.    end
  148.    close(datafile)
  149.  
  150.    maxplay = numplay
  151.    do i=1 to words(oddn)
  152.       if numplay = word(oddn,i) then
  153.          maxplay = word(evenn,i)
  154.    end
  155.  
  156.    if numplay < 3 then inftle = mp_t6
  157.    if numplay > 2 & numplay < 5 then inftle = mp_t7
  158.    if numplay > 4 & numplay < 7 then inftle = mp_t8
  159.    if numplay > 6 & numplay < 9 then inftle = mp_t9
  160.    if numplay > 8 then inftle = mp_t10
  161.  
  162.    do i=1 to counter
  163.       if numplay < 5 then do
  164.          matches.i = "**-**   **-**"
  165.          if numplay > 2 then
  166.             matches.i = matches.i"   **-**   **-**"
  167.       end
  168.       else do
  169.          matches.i = "**-**  **-**  **-**  **-**  **-**  **-**"
  170.          if numplay=7 | numplay = 8 then
  171.             matches.i = matches.i"  **-**  **-**"
  172.          if numplay > 8 then
  173.             matches.i = matches.i"  **-**  **-**  **-**  **-**"
  174.       end
  175.    end
  176.  
  177.    sel=-1
  178.    search_team = strip(search_team)
  179.    do i=1 to counter
  180.       if pos(search_team,teams.i) > 0 then
  181.          sel = i
  182.    end
  183.    i   = 0
  184.    mtp = 0
  185.    if sel > 0 then do
  186.       if open(datafile,league_file || input2_file,'r') then do
  187.          do while ~eof(datafile)
  188.             line = readln(datafile)
  189.             if pos(separator,line) = 0 then do
  190.                home_team = strip(substr(line,1,30))
  191.                goals_for = strip(substr(line,32,2))
  192.                goals_aga = strip(substr(line,37,2))
  193.                away_team = strip(substr(line,41,30))
  194.  
  195.                strng = strip(teams.sel)
  196.                if strng = home_team then do
  197.                   do i=1 to counter
  198.                      if away_team = teams.i then do
  199.                         do ah=1 to maxplay by 2
  200.                            if word(matches.i,ah) = "**-**" then do
  201.                               wi = wordindex(matches.i,ah)
  202.                               if pos(not_played,line) > 0 then
  203.                                  matches.i = overlay(".....",matches.i,wi,5)
  204.                               else do
  205.                                  matches.i = overlay(right(goals_for,2,' ')||mp_t17||left(goals_aga,2,' '),matches.i,wi,5)
  206.                                  mtp = mtp + 1
  207.                               end
  208.                               leave
  209.                            end
  210.                         end
  211.                      end
  212.                   end
  213.                end
  214.                if strng = away_team then do
  215.                   do i=1 to counter
  216.                      if home_team = teams.i then do
  217.                         do ah=2 to maxplay by 2
  218.                            if word(matches.i,ah) = "**-**" then do
  219.                               wi = wordindex(matches.i,ah)
  220.                               if pos(not_played,line) > 0 then
  221.                                  matches.i = overlay(".....",matches.i,wi,5)
  222.                               else do
  223.                                  matches.i = overlay(right(goals_aga,2,' ')||mp_t17||left(goals_for,2,' '),matches.i,wi,5)
  224.                                  mtp = mtp + 1
  225.                               end
  226.                               leave
  227.                            end
  228.                         end
  229.                      end
  230.                   end
  231.                end
  232.             end
  233.          end
  234.          close(datafile)
  235.       end
  236.       else do
  237.          say
  238.          say mp_error
  239.          say
  240.          say mp_t2"'"league_file || input2_file"'"mp_t3
  241.          exit
  242.       end
  243.       do i=1 to counter
  244.          if sel ~= i then do
  245.             do k=1 to words(matches.i)
  246.                if word(matches.i,k) = "**-**" then do
  247.                   wi = wordindex(matches.i,k)
  248.                   matches.i = overlay("     ",matches.i,wi,5)
  249.                end
  250.             end
  251.          end
  252.       end
  253.  
  254.       say
  255.       say center(mp_t11"'"league_title"'",78)
  256.       und = "-------------------------------------------------------------------------------"
  257.       say und
  258.       say
  259.       say mp_t12": "teams.sel"   "mp_t13
  260.       say
  261.       say
  262.       say
  263.       inftle = inftle"    "mp_t12
  264.       itf = length(und) - 4
  265.       under  = left("-",itf,'-')
  266.       say "    "inftle
  267.       say "    "under
  268.       do i=1 to counter
  269.          if sel ~= i then
  270.             say "    "matches.i"    "teams.i
  271.       end
  272.       say
  273.       say
  274.       say
  275.       say "    "mp_t14""mtp
  276.       say
  277.       say
  278.       say "-------------------------------------------------------------------------------"
  279.       say
  280.    end
  281.    else do
  282.       say
  283.       say mp_error
  284.       say
  285.       say mp_t15" '"search_team"' "mp_t16
  286.       exit
  287.    end
  288. end
  289. else do
  290.    say
  291.    say mp_error
  292.    say
  293.    say mp_t2"'"league_file || input_file"'"mp_t3
  294. end
  295.  
  296. exit